package com.platform.feign.spring.controller;

import com.platform.feign.spring.common.CommonResponse;
import com.platform.feign.spring.dto.req.MapPredictTripReqDto;
import com.platform.feign.spring.dto.res.MapPathResDto;
import com.platform.feign.spring.dto.res.UploadHeadResDto;
import com.platform.feign.spring.enums.MapTypeEnum;
import com.platform.feign.spring.other.IMapInteractiveApi;
import com.platform.feign.spring.other.IUserFile;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author hgx
 */
@Controller
public class MainController {

    @Resource
    private IMapInteractiveApi mapInteractiveApi;
    @Resource
    private IUserFile userFile;

    @GetMapping("/feignTest")
    @ResponseBody
    public String feignTest() {
        MapPredictTripReqDto reqDto = new MapPredictTripReqDto();
        reqDto.setDepartTime(new Date());
        reqDto.setFromLngLat("104.138932,31.659668");
        reqDto.setToLngLat("104.064404,30.56644");
        reqDto.setChannelCode("test");
        reqDto.setMapType(MapTypeEnum.TENCENT);
        reqDto.setTimeRang("20:00,21:00");
        MapPathResDto mapPathResDto = mapInteractiveApi.predictTrip(reqDto);
        return mapPathResDto.toString();

    }

    @PostMapping("/upload")
    @ResponseBody
    public String uploadTest(@RequestParam("file") MultipartFile file) {
        String stringCommonResponse = userFile.uploadFile(file);
        return stringCommonResponse;

    }

}
